<template>
	<view class="container">
		<!--TODO  请在这里编写界面代码 -->
		<view class="" style="display: flex;flex-direction: column;align-items: center;">
			<image src="../../static/logo.png" mode="widthFix" style="width: 200rpx;"></image>
		</view>
		<uni-forms ref="form" :rules="{}">
			<uni-forms-item label="" name="">
				<uni-easyinput v-model="dataform.name" placeholder="请输入用户名" />
			</uni-forms-item>

			<uni-forms-item label="" name="">
				<uni-easyinput v-model="dataform.password" type="password" placeholder="请输入密码" />
			</uni-forms-item>

			<uni-forms-item label="" name="">
				<button type="primary" @click="login">登录</button>
			</uni-forms-item>
		</uni-forms>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				// TODO 请在这里定义 表单数据dataform
				dataform: {
					"name": "",
					"password": ""
				}
			}
		},
		methods: {
			login() {
				//TODO 请在这里 实现登录逻辑,请根据success属性判断登录是否成功
				uni.request({
					url: 'http://127.0.0.1:8090/app1/user/login',
					method: 'POST',
					data: this.dataform,
					success: res => {
						if (res.data.success) {
							uni.showToast({
								title: '成功',
								icon: 'none'
							});
						} else {
							uni.showToast({
								title: '失败',
								icon: 'none'
							});
						}
					},
					fail: () => {
						uni.showToast({
							title: '网络错误',
							icon: 'none'
						});
					},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>